#include "UI.h"

const string UI::WELCOME_MESSAGE = "Welcome to PowerSchedule!";

UI::UI(void)
{
	display = programLogic.getMainDisplay();
}


UI::~UI(void)
{
}

void UI::displayWelcomeMessage()
{
	cout << WELCOME_MESSAGE << endl;
	cout << "Today's tasks: " << endl;
	showToUser();
}

void UI::startProgram()
{
	cout << "Command: " ;
    string userCommand;
	getline(cin, userCommand);
	while (userCommand != "exit")
	{
       try {
	   programLogic.processUserCommand(userCommand);
       showToUser();
	   }
	   catch ( char *str) {
		   cout << "Exception raised: " << str << endl;
	   }
	   cout << "Command: ";
	   getline(cin, userCommand);
	}

}

void UI::showToUser()
{
	display = programLogic.getMainDisplay();

	for (unsigned i=0; i<display.size(); i++)
	{
		cout << i+1 << ". " << display[i].toString() << endl;
	}

}